package org.rcy.framework.thrift.metadata;

import java.io.Serializable;
import java.lang.reflect.Type;

public class FieldValueMetaData implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * Thrift的数据格式
	 */
	public final byte type;
	/**
	 * Java类型
	 */
	public final JavaType javaType;

	private final boolean isTypedefType;
	private final String typedefName;
	private final boolean isBinary;

	public FieldValueMetaData(byte type, Type javaType, boolean binary) {
		this.type = type;
		this.javaType = JavaType.determine(javaType);
		this.isTypedefType = false;
		this.typedefName = null;
		this.isBinary = binary;
	}

	public FieldValueMetaData(byte type,Type javaType) {
		this(type,javaType, false);
	}

	public FieldValueMetaData(byte type,Type javaType, String typedefName) {
		this.type = type;
		this.javaType = JavaType.determine(javaType);
		this.isTypedefType = true;
		this.typedefName = typedefName;
		this.isBinary = false;
	}

	public boolean isTypedef() {
		return isTypedefType;
	}

	public String getTypedefName() {
		return typedefName;
	}

	public boolean isBinary() {
		return isBinary;
	}
}
